package com.example.outdoor;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class RemoveTable extends Activity implements OnClickListener{
	Button Avenue;
	Button Condition,Obstraction,BillBord,btnGoBackRemoveTables;
	SQLiteDatabase db1 = null;
	private static String DBNAME = "OutdoorAppDB.db";
	@Override
	 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.removetable);
        db1 = openOrCreateDatabase(DBNAME, Context.MODE_PRIVATE,null);
        Avenue=(Button)findViewById(R.id.btnRemoveAvenue);
        Obstraction=(Button)findViewById(R.id.btnRemoveObstraction);
        BillBord=(Button)findViewById(R.id.btnRemoveBillBoard);
        Condition=(Button)findViewById(R.id.btnRemoveCondition);
        btnGoBackRemoveTables=(Button)findViewById(R.id.btnGoBackRemoveTables);
        Avenue.setOnClickListener(this);
        Obstraction.setOnClickListener(this);
        BillBord.setOnClickListener(this);
        Condition.setOnClickListener(this);
        btnGoBackRemoveTables.setOnClickListener(this);
        
	}
	
	@Override
	public void onClick(View v) {
		
		switch(v.getId()){
		case R.id.btnRemoveAvenue:
			DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
			    @Override
			    public void onClick(DialogInterface dialog, int which) {
			        switch (which){
			        case DialogInterface.BUTTON_POSITIVE:
			        	
			        	db1.execSQL("Delete from tblAvenue"); 
			        	Toast.makeText(getBaseContext(), "Records are deleted successfully", Toast.LENGTH_SHORT).show();
			            break;

			        case DialogInterface.BUTTON_NEGATIVE:
			            //No button clicked
			            break;
			        }
			    }
			};

			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("Are you sure you want to delete?").setPositiveButton("Yes", dialogClickListener)
			    .setNegativeButton("No", dialogClickListener).show();
			
			break;
		case R.id.btnRemoveBillBoard:
			DialogInterface.OnClickListener dialogClickListener1 = new DialogInterface.OnClickListener() {
			    @Override
			    public void onClick(DialogInterface dialog, int which) {
			        switch (which){
			        case DialogInterface.BUTTON_POSITIVE:
			        	db1.execSQL("Delete from tblBillboard"); 
			        	Toast.makeText(getBaseContext(), "Records are deleted successfully", Toast.LENGTH_SHORT).show();
			            break;

			        case DialogInterface.BUTTON_NEGATIVE:
			            //No button clicked
			            break;
			        }
			    }
			};

			AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
			builder1.setMessage("Are you sure you want to delete?").setPositiveButton("Yes", dialogClickListener1)
			    .setNegativeButton("No", dialogClickListener1).show();
			
			break;
		case R.id.btnRemoveObstraction:
			DialogInterface.OnClickListener dialogClickListener2 = new DialogInterface.OnClickListener() {
			    @Override
			    public void onClick(DialogInterface dialog, int which) {
			        switch (which){
			        case DialogInterface.BUTTON_POSITIVE:
			        	db1.execSQL("Delete from tblOBSTRUCTION"); 
			        	Toast.makeText(getBaseContext(), "Records are deleted successfully", Toast.LENGTH_SHORT).show();
			            break;

			        case DialogInterface.BUTTON_NEGATIVE:
			            //No button clicked
			            break;
			        }
			    }
			};

			AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
			builder2.setMessage("Are you sure you want to delete?").setPositiveButton("Yes", dialogClickListener2)
			    .setNegativeButton("No", dialogClickListener2).show();
			
			break;
		case R.id.btnRemoveCondition:
			DialogInterface.OnClickListener dialogClickListener3 = new DialogInterface.OnClickListener() {
			    @Override
			    public void onClick(DialogInterface dialog, int which) {
			        switch (which){
			        case DialogInterface.BUTTON_POSITIVE:
			        	db1.execSQL("Delete from tblCondition"); 
			        	Toast.makeText(getBaseContext(), "Records are deleted successfully", Toast.LENGTH_SHORT).show();
			            break;

			        case DialogInterface.BUTTON_NEGATIVE:
			            //No button clicked
			            break;
			        }
			    }
			};

			AlertDialog.Builder builder3 = new AlertDialog.Builder(this);
			builder3.setMessage("Are you sure  you want to delete?").setPositiveButton("Yes", dialogClickListener3)
			    .setNegativeButton("No", dialogClickListener3).show();
			
			break;
		case R.id.btnGoBackRemoveTables:
			Intent ourGoBackIntent=new Intent(RemoveTable.this,Tables.class);
			startActivity(ourGoBackIntent);
			break;
			default:
				break;
	}
	}
	
}
